package com.example.intercepter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * SpringBoot的配置类
 */
@SpringBootConfiguration
public class webAdapter  extends WebMvcConfigurationSupport {
	
	@Autowired
	private SessionInterceptor sessionInterceptor;
	
	/**
	 * 配置拦截器
	 */
	public void addInterceptors(InterceptorRegistry registry) {
				
		registry.addInterceptor(sessionInterceptor).addPathPatterns("/**");
		
	
	}
	
	
	/**
	 * 配置swagger2访问的静态资源映射
	 * Override this method to add resource handlers for serving static resources.
	 * @see ResourceHandlerRegistry
	 */
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		
		registry.addResourceHandler("swagger-ui.html")
        .addResourceLocations("classpath:/META-INF/resources/");

       registry.addResourceHandler("/webjars/**")
        .addResourceLocations("classpath:/META-INF/resources/webjars/");


	}

}
